package com.briup.day12;

/**
 * @author ThinkBook
 */
//定义父类：员工
public class Employee {
    //工号、姓名
    private String id;
    private String name;

    public String getName() {
        return name;
    }

    public String getId() {
        return id;
    }

    public Employee() {}

    public Employee(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public void doWork() {
        System.out.println("员工开始工作...");
    }
    //静态方法
    public static void sFunction() {
        System.out.println("in Employee, sFunction ...");
    }
}

//定义子类：程序员
class Programmer extends Employee {
    //等级：初级、中级、高级、资深
    private String grade;


    public Programmer() {
        //默认会调用父类无参构造器
        //super();
    }

    public Programmer(String id,String name,String grade) {
        //显式调用父类构造器
        super(id,name);
        this.grade = grade;
    }

    //重写方法
    //	@Override是注解，用于标识该方法为重写的方法，大家可以不用管
    @Override
    public void doWork() {
        //super.doWork();

        System.out.println("我是程序员，级别为" + grade + ", 开始工作：写代码");
    }
    //定义静态方法，形式跟 父类中static方法一模一样
    //Method does not override method from its superclass
    //@Override
    public static void sFunction() {
        System.out.println("in Programmer, sFunction ...");
    }
    @Override
    public String toString() {
        return "Programmer{" +
                "id='" + super.getId() + '\'' +
                ", name='" + super.getName() + '\'' +
                "grade='" + grade + '\'' +
                '}';
    }
}

//定义子类：经理
class Manager extends Employee {
    //奖金
    private double bonus;

    public Manager() {
        super();
    }

    public Manager(String id,String name,double bonus) {
        super(id,name);
        this.bonus = bonus;
    }

    //重写方法
    @Override
    public void doWork() {
        System.out.println("我是经理，有津贴" + bonus + ", 开始工作：安排部门员工任务");
    }
}
